/**
 */
package org.aphelie.romancer.model.chronicle.impl;

import java.util.Collection;
import org.aphelie.romancer.model.chronicle.Chronicle;
import org.aphelie.romancer.model.chronicle.ChroniclePackage;

import org.aphelie.romancer.model.chronicle.Personnage;
import org.aphelie.romancer.model.chronicle.document.Document;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Chronicle</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.aphelie.romancer.model.chronicle.impl.ChronicleImpl#getCharacters <em>Characters</em>}</li>
 *   <li>{@link org.aphelie.romancer.model.chronicle.impl.ChronicleImpl#getPersonnages <em>Personnages</em>}</li>
 *   <li>{@link org.aphelie.romancer.model.chronicle.impl.ChronicleImpl#getDocuments <em>Documents</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ChronicleImpl extends EObjectImpl implements Chronicle {
	/**
	 * The cached value of the '{@link #getCharacters() <em>Characters</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCharacters()
	 * @generated
	 * @ordered
	 */
	protected EList<org.aphelie.romancer.model.chronicle.entity.Character> characters;

	/**
	 * The cached value of the '{@link #getPersonnages() <em>Personnages</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPersonnages()
	 * @generated
	 * @ordered
	 */
	protected EList<Personnage> personnages;

	/**
	 * The cached value of the '{@link #getDocuments() <em>Documents</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDocuments()
	 * @generated
	 * @ordered
	 */
	protected EList<Document> documents;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ChronicleImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ChroniclePackage.Literals.CHRONICLE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<org.aphelie.romancer.model.chronicle.entity.Character> getCharacters() {
		if (characters == null) {
			characters = new EObjectResolvingEList<org.aphelie.romancer.model.chronicle.entity.Character>(org.aphelie.romancer.model.chronicle.entity.Character.class, this, ChroniclePackage.CHRONICLE__CHARACTERS);
		}
		return characters;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Personnage> getPersonnages() {
		if (personnages == null) {
			personnages = new EObjectContainmentEList<Personnage>(Personnage.class, this, ChroniclePackage.CHRONICLE__PERSONNAGES);
		}
		return personnages;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Document> getDocuments() {
		if (documents == null) {
			documents = new EObjectContainmentEList<Document>(Document.class, this, ChroniclePackage.CHRONICLE__DOCUMENTS);
		}
		return documents;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ChroniclePackage.CHRONICLE__PERSONNAGES:
				return ((InternalEList<?>)getPersonnages()).basicRemove(otherEnd, msgs);
			case ChroniclePackage.CHRONICLE__DOCUMENTS:
				return ((InternalEList<?>)getDocuments()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ChroniclePackage.CHRONICLE__CHARACTERS:
				return getCharacters();
			case ChroniclePackage.CHRONICLE__PERSONNAGES:
				return getPersonnages();
			case ChroniclePackage.CHRONICLE__DOCUMENTS:
				return getDocuments();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ChroniclePackage.CHRONICLE__CHARACTERS:
				getCharacters().clear();
				getCharacters().addAll((Collection<? extends org.aphelie.romancer.model.chronicle.entity.Character>)newValue);
				return;
			case ChroniclePackage.CHRONICLE__PERSONNAGES:
				getPersonnages().clear();
				getPersonnages().addAll((Collection<? extends Personnage>)newValue);
				return;
			case ChroniclePackage.CHRONICLE__DOCUMENTS:
				getDocuments().clear();
				getDocuments().addAll((Collection<? extends Document>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ChroniclePackage.CHRONICLE__CHARACTERS:
				getCharacters().clear();
				return;
			case ChroniclePackage.CHRONICLE__PERSONNAGES:
				getPersonnages().clear();
				return;
			case ChroniclePackage.CHRONICLE__DOCUMENTS:
				getDocuments().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ChroniclePackage.CHRONICLE__CHARACTERS:
				return characters != null && !characters.isEmpty();
			case ChroniclePackage.CHRONICLE__PERSONNAGES:
				return personnages != null && !personnages.isEmpty();
			case ChroniclePackage.CHRONICLE__DOCUMENTS:
				return documents != null && !documents.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //ChronicleImpl
